/* GUI CONVERTED from rerpiq.p (converter v1.75) Wed Aug 16 23:18:51 2000 */
/* rerpiq.p - REPETITIVE PART SCHEDULE INQUIRY                          */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* web convert rerpiq.p (converter v1.00) Fri Oct 10 13:57:58 1997 */
/* web tag in rerpiq.p (converter v1.00) Mon Oct 06 14:18:37 1997 */
/*F0PN*/ /*K0ZL*/ /*                                                    */
/*V8:ConvertMode=Report                                        */
/* REVISION: 5.0      LAST MODIFIED: 02/02/89   BY: EMB */
/* REVISION: 5.0          LAST EDIT: 05/03/89   BY: WUG *B098* */
/* REVISION: 5.0      LAST MODIFIED: 08/27/90   BY: EMB D040*/
/* REVISION: 7.0      LAST MODIFIED: 02/29/92   BY: smm F230*/
/* Revision: 7.3          Last edit: 11/19/92   By: jcd *G339* */
/* REVISION: 7.3      LAST MODIFIED: 01/21/93   BY: emb G689*/
/* REVISION: 7.3      LAST MODIFIED: 04/23/93   BY: emb GA28*/
/* REVISION: 7.3      LAST MODIFIED: 08/03/94   BY: ais GL09*/
/* REVISION: 7.3      LAST MODIFIED: 08/11/94   BY: str FQ04*/
/* REVISION: 7.3    LAST MODIFIED: 07/30/96 BY *G2B3* Julie Milligan      */
/* REVISION: 8.6      LAST MODIFIED: 10/15/97   BY  bvm *K0ZL* */

/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan     */
/* REVISION: 9.0      LAST MODIFIED: 10/14/98   BY: *J32B* Felcy D'Souza  */
/* REVISION: 9.0      LAST MODIFIED: 03/13/99   BY: *M0BD* Alfred Tan     */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/09/00   BY: *N0GD* Peggy Ng  */

         /* DISPLAY TITLE */

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

         {mfdtitle.i "b+ "} /*GA28*/

/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rerpiq_p_1 "   Completed + Scrap"
/* MaxLen: Comment: */

/*N0GD*  &SCOPED-DEFINE rerpiq_p_2 "Monday"         */
/*N0GD*  /* MaxLen: Comment: */                     */

/*N0GD*  &SCOPED-DEFINE rerpiq_p_3 "Friday"         */
/*N0GD*  /* MaxLen: Comment: */                     */

/*N0GD*  &SCOPED-DEFINE rerpiq_p_4 "Wednesday"      */
/*N0GD*  /* MaxLen: Comment: */                     */

/*N0GD*  &SCOPED-DEFINE rerpiq_p_5 "Saturday"       */
/*N0GD*  /* MaxLen: Comment: */                     */

&SCOPED-DEFINE rerpiq_p_6 "Scheduled"
/* MaxLen: Comment: */

&SCOPED-DEFINE rerpiq_p_7 "Qty Open"
/* MaxLen: Comment: */

/*N0GD*  &SCOPED-DEFINE rerpiq_p_8 "Tuesday"        */
/*N0GD*  /* MaxLen: Comment: */                     */

/*N0GD*  &SCOPED-DEFINE rerpiq_p_9 "Sunday"         */
/*N0GD*  /* MaxLen: Comment: */                     */

/*N0GD*  &SCOPED-DEFINE rerpiq_p_10 "Thursday"      */
/*N0GD*  /* MaxLen: Comment: */                     */

/* ********** End Translatable Strings Definitions ********* */

/*D040*/ define variable site like rps_site.
/*F230*/ define variable prline like rps_line.
         define variable due like rps_due_date.
         define variable part like rps_part.
         define variable open_ref like rps_qty_req column-label {&rerpiq_p_7}.
         define variable wday as character format "x(9)".
         define variable wdays like wday extent 7.
/*G2B3*          initial ["   Sunday","   Monday","  Tuesday","Wednesday", */
/*G2B3*                   " Thursday","   Friday"," Saturday"]. */
/*N0GD*   ****BEGIN DELETED CODE****
* /*G2B3*/  initial [{&rerpiq_p_9},{&rerpiq_p_2},{&rerpiq_p_8},{&rerpiq_p_4},
* /*G2B3*/           {&rerpiq_p_10},{&rerpiq_p_3},{&rerpiq_p_5}].
**N0GD*   ****END DELETED CODE**** */
         define variable i as integer.
/*G689*/ define variable rps_start like rps_due_date.

         part = global_part.
/*F230*/ site = global_site.

/*N0GD*/    /****BEGIN NEW CODE****/
        wdays[1]=getTermLabelRt("SUNDAY",9).
        wdays[2]=getTermLabelRt("MONDAY",9).
        wdays[3]=getTermLabelRt("TUESDAY",9).
        wdays[4]=getTermLabelRt("WEDNESDAY",9).
        wdays[5]=getTermLabelRt("THURSDAY",9).
        wdays[6]=getTermLabelRt("FRIDAY",9).
        wdays[7]=getTermLabelRt("SATURDAY",9).
/*N0GD*/    /****END NEW CODE****/

/*G689*/ /* Added section*/
         find first lnd_det no-lock where lnd_site = site
         and lnd_part = part no-error.
         if available lnd_det then prline = lnd_line.

         find first rpc_ctrl no-lock no-error.
         if available rpc_ctrl then do:
            rps_start = today.
            if rpc_wk_start < 8 then do:
               if rpc_wk_start = 0 then rps_start = rps_start - rpc_sch_bck.
               else do:
                  if weekday(today) >= rpc_wk_start
                  then rps_start = rps_start
                     - weekday(rps_start) + rpc_wk_start.
                  else rps_start = rps_start
                     - weekday(rps_start) + rpc_wk_start - 7.
               end.
            end.
         end.
/*G689*/ /* End of added section*/

         due = today.

         if weekday(due) = 1 then due = due + 1.
         else due = due + 2 - weekday(due).

/*F230*/ /* New Selection Form */
         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            part
            pt_desc1 no-label format "x(16)"
            site
            prline
            due
         with frame a no-underline width 80 attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

/*K0ZL*/ {wbrp01.i}

         repeat:

/*K0ZL*/    if c-application-mode <> 'web' then
            update part site
/*F230*/    prline
            due with frame a editing:

               if frame-field = "part" then do:

                  /* FIND NEXT/PREVIOUS RECORD */
                  {mfnp.i rps_mstr part rps_part part rps_part rps_part}
                  if recno <> ? then do:
                     display rps_part @ part with frame a.
                     find pt_mstr no-lock where pt_part = rps_part no-error.
                     if available pt_mstr then
/*F230*/             display pt_desc1 with frame a.
/*F230*                 pt_desc2 @ pt_desc1 */
                     else display " " @ pt_desc1 with frame a.
                     recno = ?.
                  end.
               end.
               else if frame-field = "site" then do:
                  /* FIND NEXT/PREVIOUS RECORD */
/*G689*           {mfnp.i si_mstr site si_site site si_site si_site} */
/*G689*/          {mfnp05.i rps_mstr rps_part
                     "rps_part = input part" rps_site "input site"}
                  if recno <> ? then do:
                     display
                        rps_site @ site
                        rps_line @ prline
                     with frame a.
                     recno = ?.
                  end.
               end.
/*F230*/       /* Added section */
               else if frame-field = "prline" then do:
                  /*FIND NEXT/PREVIOUS RECORD */
/*G689*/          {mfnp05.i rps_mstr rps_part
                  "rps_site = input site and rps_part = input part"
                   rps_line "input prline"}
/*G689*/          if recno <> ? then display rps_line @ prline with frame a.

/*G689*           {mfnp.i ln_mstr site ln_site prline ln_line ln_line}
                  if recno <> ? then do with frame a:
                     display ln_site @ site ln_line @ prline.
                  end.
                  */
               end.
               else do:
                  status input.
                  readkey.
                  apply lastkey.
               end.
            end.

/*K0ZL*/ {wbrp06.i &command = update &fields = "  part site  prline due" &frm = "a"}

/*K0ZL*/ if (c-application-mode <> 'web') or
/*K0ZL*/ (c-application-mode = 'web' and
/*K0ZL*/ (c-web-request begins 'data')) then do:

            find pt_mstr no-lock where pt_part = part no-error.
            if not available pt_mstr then do:
               {mfmsg.i 16 3}
/*K0ZL*/       if c-application-mode = 'web' then return.
               undo, retry.
            end.

            display pt_part @ part pt_desc1 with frame a.

            find si_mstr no-lock where si_site = site no-error.
            if not available si_mstr then do with frame a:
               {mfmsg.i 708 3}

/*K0ZL*/       if c-application-mode = 'web' then return.
               else next-prompt site.
               undo, retry.
            end.

/*G689*/    /* Added section*/
            find first ln_mstr no-lock where ln_line = prline no-error.
            if not available ln_mstr
/*GA28*/    and prline > ""
            then do:
               {mfmsg.i 8524 3}

/*K0ZL*/       if c-application-mode = 'web' then return.
               else next-prompt prline with frame a.
               undo, retry.
            end.

            find first ln_mstr no-lock where ln_line = prline
            and ln_site = site no-error.
            if not available ln_mstr then do:
/*GA28*/       find first ln_mstr no-lock where ln_site = site no-error.
/*GA28*/       if available ln_mstr then do:
                  {mfmsg.i 8526 3}

/*K0ZL*/          if c-application-mode = 'web' then return.
                  else next-prompt prline with frame a.
                  undo, retry.
/*GA28*/       end.
            end.

            find first rps_mstr no-lock where rps_part = part
            and rps_site = site
            and rps_line = prline
            no-error.
            if not available rps_mstr then do:
/*FQ04               {mfmsg.i 8527 3}    */
/*FQ04*/       {mfmsg.i 7156 3}
/*K0ZL*/       if c-application-mode = 'web' then return.
               undo,retry.
            end.
/*G689*/    /* End of added section*/

            hide frame b.

/*K0ZL*/ end.

            /* SELECT PRINTER */
            {mfselprt.i "terminal" 80}

            /* FIND AND DISPLAY */
            for each rps_mstr no-lock where rps_part = part
/*D040*/    and rps_site = site and
/*F230*/    rps_line = prline
            and (rps_due_date >= due or due = ?)
            with frame b width 80 no-attr-space:

               /* SET EXTERNAL LABELS */
               setFrameLabels(frame b:handle).

/*G339*/       
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


               open_ref = max(rps_qty_req - max(rps_qty_comp,0),0).
/*G689*/       if rps_due_date < rps_start then open_ref = 0.

/*J32B*/ /* COMMENTED OUT AS WEEKDAYS ARE NOT DISPLAYED PROPERLY IN CHINEESE*/
/*J32B*/ /* LANGUAGE WHEN RIGHT JUSTIFIED WITH FILL CHARACTERS IN THE       */
/*J32B*/ /* BEGINING FOR THE DISPLAY PURPOSE.                               */
/*J32B** /*G2B3*/       {gprun.i ""gprtfill.p"" "(input 9,
 *               input wdays[weekday(rps_due_date)],
 *               input "" "",
 *               output wday)"}
 *J32B**/

               display
/*G2B3*           wdays[weekday(rps_due_date)] @ wday no-label */
/*J32B** /*G2B3*/ wday no-label */
/*J32B*/          wdays[weekday(rps_due_date)] @ wday no-label
/*G689*/          rps_rel_date
                  rps_due_date
/*GL09*           rps_qty_req rps_qty_comp open_ref                    */
/*GL09*/          rps_qty_req  column-label {&rerpiq_p_6}
/*GL09*/          rps_qty_comp column-label {&rerpiq_p_1}
/*GL09*/          open_ref
               with frame b STREAM-IO /*GUI*/ .

            end.

            {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/

            {mfmsg.i 8 1}

            global_part = part.
/*F230*/    global_site = site.

         end.

/*K0ZL*/ {wbrp04.i &frame-spec = a}
